package cn.lhd.bookadviserapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Spinner;
import android.widget.TextView;

import java.util.List;

public class MainActivity extends Activity {

    private BookExpert expert = new BookExpert();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void onClickFindBooks(View view){
        Spinner spinner = (Spinner) findViewById(R.id.spinner);
        String category = String.valueOf(spinner.getSelectedItem());
        List<String> books_list  = expert.getBooks(category);
        StringBuilder books = new StringBuilder();

        for (String book : books_list){
            books.append(book);
        }

        TextView textView = (TextView) findViewById(R.id.textView);
        textView.setText(books);
    }
}
